<template>
  <div class="rightbox" v-cloak>
    <h1>公司中心 > 方案列表</h1>
    <el-table
    :data="contentList"
    border
    style="width: 96%;margin:2%">
      <el-table-column
        prop="title"
        label="方案标题">
      </el-table-column>
      <el-table-column
        prop=""
        label="封面图">
        <template slot-scope="scope">
          <img :src="scope.row.thumbnail" style="width:200px;">
        </template>
      </el-table-column>
      <el-table-column
        prop=""
        label="状态">
        <template slot-scope="scope">
          <span v-if="scope.row.state == 0">待审核</span>
          <span v-if="scope.row.state == 1" style="color: green">已通过</span>
          <span v-if="scope.row.state == -1" style="color: #f00">不通过({{scope.row.remark}})</span>
        </template>
      </el-table-column>
      <el-table-column
        prop=""
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="Modify(scope)">修改</el-button>
          <el-button type="text" size="small" @click="View(scope)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="page" v-if="total >= pagelimit">
      <el-pagination
        background
        layout="prev, pager, next"
        @current-change="handleCurrentChange"
        :page-size="pagelimit"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      contentList: [],
      contype: [],
      pagelimit: 5,
      designindex: '',
      pageindex: 0,
      total: '',
      casename: ''
    }
  },
  methods: {
    Search: function () {
      var that = this
      that.getList()
    },
    getList: function () {
      var that = this
      that.$axios.request('post', '/CompanyScheme/Index', {
        Pagelimit: that.pagelimit,
        Pageindex: that.pageindex
      })
        .then((res) => {
          if (res.code === 0) {
            that.contentList = res.data.datalist
            that.total = res.data.total
          }
        })
    },
    handleCurrentChange (val) {
      var that = this
      that.pageindex = val
      that.getList()
    },
    Modify: function (scope) {
      var that = this
      that.$router.push({
        name: 'caseAdd',
        params: {
          schemeIndex: scope.row.schemeIndex
        }
      })
    },
    View: function (scope) {
      var that = this
      that.$router.push({
        name: 'caseDetail',
        query: {
          schemeIndex: scope.row.schemeIndex
        }
      })
    }
  },
  mounted () {
    this.getList()
  }
}
</script>
